package com.material.mdbook.utils;

/**
 * @author zhangli
 * @date 2019/3/19 17:04
 * description:
 */
public class StringUtils {

    public static boolean sameStr(String str1, String str2) {
        str1 = str1.replaceAll(" ", "");
        str1 = str1.replaceAll("\\s", "");
        str1 = str1.replaceAll("\n", "");
        str1 = str1.replaceAll("\\\\0", "");
        str2 = str2.replaceAll(" ", "");
        str2 = str2.replaceAll("\\s", "");
        str2 = str2.replaceAll("\n", "");
        str2 = str2.replaceAll("\\\\0", "");

        return str1.equals(str2);
    }

    public static String outAz(String str) {
        return str.replaceAll("[A-Za-z]+", "");
    }

    /**
     * 过滤出中文
     *
     * @param chin
     * @return
     */
    public static String filterChinese(String chin) {
        chin = chin.replaceAll("[^(\\u4e00-\\u9fa5)]", "");
        return chin;
    }

    /**
     * 过滤出英文
     *
     * @param alph
     * @return
     */
    public static String filterAlphabet(String alph) {
        alph = alph.replaceAll("[^(A-Za-z)]", "");
        return alph;
    }

    /**
     * 过滤出数字
     *
     * @param number
     * @return
     */
    public static String filterNumber(String number) {
        number = number.replaceAll("[^(0-9)]", "");
        return number;
    }

    /**
     * 过滤出中文数字英文
     *
     * @param character
     * @return
     */
    public static String filterAll(String character) {
        character = character.replaceAll("[^(a-zA-Z0-9\\u4e00-\\u9fa5)]", "");
        return character;
    }

    public static String replaceAll(String str,String f){
        return str.replaceAll(f,"");
    }
}
